package com.cskaoyan.servlet;

import com.cskaoyan.bean.MarketCoupon;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AdminSearchHistoryService;
import com.cskaoyan.service.AdminSearchHistoryServiceImpl;
import com.cskaoyan.util.ResponseUtil;
import com.cskaoyan.util.StringUtil;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//小组接口获得搜索历史的实现

@WebServlet("/admin/history/*")
public class AdminSearchHistoryServlet extends WdBaseServlet {

    AdminSearchHistoryService adminHistoryService=  new AdminSearchHistoryServiceImpl();

    @SneakyThrows
    private void list(HttpServletRequest request, HttpServletResponse response){


        String keyword = request.getParameter("keyword");


        Integer userId = StringUtil.isEmpty(request.getParameter("userId")) ? null : Integer.parseInt(request.getParameter("userId"));


        Integer page = Integer.parseInt(request.getParameter("page"));

        Integer limit = Integer.parseInt(request.getParameter("limit"));

        String sort = request.getParameter("sort");
        String order = request.getParameter("order");

        CommonData<MarketCoupon> commonData = adminHistoryService.list(userId, keyword,  page, limit, sort, order);

        ResponseUtil.responseJson(response, BaseRespVo.ok(commonData));




    }


}


